﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BestCode.Creds.Data;
using BestCode.Creds.Entities;

namespace BestCode.Creds.Business
{
    public class EntityBusiness : BusinessBase<EntityInfo>
    {
        private IEntityDao dao = DataFactory.Current.GetEntityInfoDao();

        public EntityBusiness()
        {
            setDao(dao);    
        }

        public override void PostInsert(EntityInfo entity)
        {
                EntityChildBusiness childBusiness = new EntityChildBusiness();
                childBusiness.Save(new EntityChild()
                {
                    Name = "Default_Children",
                    PicturesFolder = entity.PicturesFolder ,
                    Entity = entity
                });
        }

        public override ObservableCollection<EntityInfo> SearchByFilter(string parameter)
        {
            return new ObservableCollection<EntityInfo>(dao.GetByFilter(parameter));
        }
    }
}
